<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户信息</title>
</head>
<body>
<h1 align="center">用户信息</h1>
<div sec:authorize="isAnonymous()">
    <h2 align="center">游客您好，您还为登录博客系统<a th:href="@{/userLogin}">请登录</a></h2></div>
<div sec:authorize="isAuthenticated()">
    <h2 align="center"><span sec:authentication="name" style="color: #007bff"></span>
        您好，您的用户权限为<span sec:authentication="principal.authorities"
                        style="color:darkkhaki"></span>，您有以下权限
    </h2>
    <h2><a th:href="@{/}" class="navbar-logo">返回首页</a></h2>
    <h3><a th:href="@{/toUpdate}">修改用户名</a></h3>
    <p><a th:href="@{/deleteUser}" onclick="return confirm('您确定要注销当前用户吗？')">注销当前用户</a></p>
</div>
<hr>
<div sec:authorize="hasRole('ROLE_common')">
    <h3>普通用户</h3>
    <p>浏览文章</p>
    <p>评论</p>
</div>
<div sec:authorize="hasAnyAuthority('ROLE_admin')">
    <h3>管理员</h3>
    <p>浏览文章</p>
    <p>评论</p>
    <p>进入后台管理页面</p>
    <p>文章发布、删除、修改</p>
    <p>评论修改、删除</p>
</div>
</body>
</html>